
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import '@/locale/setting';
import { createLocaleLang, createComponentSize } from '@/store/actions';
import { isIframe } from '@/router';

import { application } from '@/hoc';

import type { AppState } from '@/store/reducers/app';



@application
@withRouter
class UseConfig extends Component<any> {

  componentDidMount() {
    const localTheme = localStorage.getItem('theme_color');
    if (localTheme && localTheme !== this.props.themeColor) {
      this.props.setThemeColor(localTheme);
    }
    if (isIframe(this.props.location.pathname)) {
      document.addEventListener('click', this.clickEventHandle, false);
    }
    window.addEventListener('message', this.messageEventHandle, false);
  }

  componentWillUnmount() {
    // window.removeEventListener('message', this.messageEventHandle);
    // document.removeEventListener('click', this.clickEventHandle);
  }

  componentDidUpdate(prevProps) {

  }


  render() {
    const { pathname } = this.props.location;
    return (
      <div>123</div>
    );
  }
}

export default connect(
  (state: AppState) => ({
    // size: state.app.size,
    // lang: state.app.lang,
    // themeColor: state.app.themeColor,
  }),
  {
    createLocaleLang,
    createComponentSize,
  }
)(UseConfig);
